<template>
  <el-date-picker
    clearable
    v-model="comValue"
    :type="props.comType"
    range-separator="至"
    start-placeholder="开始"
    end-placeholder="截止"
    :disabled-date="disabledDate"
    :value-format="props.valueFormat"
  />
</template>
<script setup>
import dayjs from 'dayjs'
const emit = defineEmits(['update:begin', 'update:end'])
const props = defineProps({
  valueFormat:{
    type:String,
    default:'YYYY-MM-DD'
  },
  begin: {
    type: String,
    default: ''
  },
  end: {
    type: String,
    default: ''
  },
  comType:{
    type:String,
    default:'daterange'
  },
  disabledDate : {
    type: Function,
    default: () => false
  }
})
const comValue = computed({
  get(val) {
    return [props.begin, props.end]
  },
  set(val) {
    if (val) {
      emit('update:begin', val[0]?val[0]:'')
      emit('update:end', val[1]?val[1]:'')
    }else{
      emit('update:begin', '')
      emit('update:end', '')
    }
  }
})
</script>
<style lang="scss" scoped></style>
